173. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2021-05-13 09:09:00 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

173.1 Files compared

#LocationFileLast Modified
1/Applications/Ampps/www/Porto 3.2.2/Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Porto/view/frontend/web/jsimagesloaded.js2016-02-10 12:44:18 +0000
2/Applications/Ampps/www/Porto v4.0.0/Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Porto/view/frontend/web/jsimagesloaded.js2016-02-10 12:44:18 +0000

173.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged1972
Changed00
Inserted00
Removed00

173.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

173.4 Active regular expressions

No regular expressions were active.

173.5 Comparison detail

1 /*! 1 /*!
2  * imagesLoaded PACKAGED v4.1.0 2  * imagesLoaded PACKAGED v4.1.0
3  * JavaScript is all like "You images are done yet or what?" 3  * JavaScript is all like "You images are done yet or what?"
4  * MIT License 4  * MIT License
5  */ 5  */
6  6 
7 /** 7 /**
8  * EvEmitter v1.0.1 8  * EvEmitter v1.0.1
9  * Lil' event emitter 9  * Lil' event emitter
10  * MIT License 10  * MIT License
11  */ 11  */
12  12 
13 /* jshint unused: true, undef: true, strict: true */ 13 /* jshint unused: true, undef: true, strict: true */
14  14 
15 ( function( global, factory ) { 15 ( function( global, factory ) {
16   // universal module definition 16   // universal module definition
17   /* jshint strict: false */ /* globals define, module */ 17   /* jshint strict: false */ /* globals define, module */
18   if ( typeof define == 'function' && define.amd ) { 18   if ( typeof define == 'function' && define.amd ) {
19     // AMD - RequireJS 19     // AMD - RequireJS
20     define( 'ev-emitter/ev-emitter',factory ); 20     define( 'ev-emitter/ev-emitter',factory );
21   } else if ( typeof module == 'object' && module.exports ) { 21   } else if ( typeof module == 'object' && module.exports ) {
22     // CommonJS - Browserify, Webpack 22     // CommonJS - Browserify, Webpack
23     module.exports = factory(); 23     module.exports = factory();
24   } else { 24   } else {
25     // Browser globals 25     // Browser globals
26     global.EvEmitter = factory(); 26     global.EvEmitter = factory();
27   } 27   }
28  28 
29 }( this, function() { 29 }( this, function() {
30  30 
31  31 
32  32 
33 function EvEmitter() {} 33 function EvEmitter() {}
34  34 
35 var proto = EvEmitter.prototype; 35 var proto = EvEmitter.prototype;
36  36 
37 proto.on = function( eventName, listener ) { 37 proto.on = function( eventName, listener ) {
38   if ( !eventName || !listener ) { 38   if ( !eventName || !listener ) {
39     return; 39     return;
40   } 40   }
41   // set events hash 41   // set events hash
42   var events = this._events = this._events || {}; 42   var events = this._events = this._events || {};
43   // set listeners array 43   // set listeners array
44   var listeners = events[ eventName ] = events[ eventName ] || []; 44   var listeners = events[ eventName ] = events[ eventName ] || [];
45   // only add once 45   // only add once
46   if ( listeners.indexOf( listener ) == -1 ) { 46   if ( listeners.indexOf( listener ) == -1 ) {
47     listeners.push( listener ); 47     listeners.push( listener );
48   } 48   }
49  49 
50   return this; 50   return this;
51 }; 51 };
52  52 
53 proto.once = function( eventName, listener ) { 53 proto.once = function( eventName, listener ) {
54   if ( !eventName || !listener ) { 54   if ( !eventName || !listener ) {
55     return; 55     return;
56   } 56   }
57   // add event 57   // add event
58   this.on( eventName, listener ); 58   this.on( eventName, listener );
59   // set once flag 59   // set once flag
60   // set onceEvents hash 60   // set onceEvents hash
61   var onceEvents = this._onceEvents = this._onceEvents || {}; 61   var onceEvents = this._onceEvents = this._onceEvents || {};
62   // set onceListeners array 62   // set onceListeners array
63   var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; 63   var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || [];
64   // set flag 64   // set flag
65   onceListeners[ listener ] = true; 65   onceListeners[ listener ] = true;
66  66 
67   return this; 67   return this;
68 }; 68 };
69  69 
70 proto.off = function( eventName, listener ) { 70 proto.off = function( eventName, listener ) {
71   var listeners = this._events && this._events[ eventName ]; 71   var listeners = this._events && this._events[ eventName ];
72   if ( !listeners || !listeners.length ) { 72   if ( !listeners || !listeners.length ) {
73     return; 73     return;
74   } 74   }
75   var index = listeners.indexOf( listener ); 75   var index = listeners.indexOf( listener );
76   if ( index != -1 ) { 76   if ( index != -1 ) {
77     listeners.splice( index, 1 ); 77     listeners.splice( index, 1 );
78   } 78   }
79  79 
80   return this; 80   return this;
81 }; 81 };
82  82 
83 proto.emitEvent = function( eventName, args ) { 83 proto.emitEvent = function( eventName, args ) {
84   var listeners = this._events && this._events[ eventName ]; 84   var listeners = this._events && this._events[ eventName ];
85   if ( !listeners || !listeners.length ) { 85   if ( !listeners || !listeners.length ) {
86     return; 86     return;
87   } 87   }
88   var i = 0; 88   var i = 0;
89   var listener = listeners[i]; 89   var listener = listeners[i];
90   args = args || []; 90   args = args || [];
91   // once stuff 91   // once stuff
92   var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; 92   var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
93  93 
94   while ( listener ) { 94   while ( listener ) {
95     var isOnce = onceListeners && onceListeners[ listener ]; 95     var isOnce = onceListeners && onceListeners[ listener ];
96     if ( isOnce ) { 96     if ( isOnce ) {
97       // remove listener 97       // remove listener
98       // remove before trigger to prevent recursion 98       // remove before trigger to prevent recursion
99       this.off( eventName, listener ); 99       this.off( eventName, listener );
100       // unset once flag 100       // unset once flag
101       delete onceListeners[ listener ]; 101       delete onceListeners[ listener ];
102     } 102     }
103     // trigger listener 103     // trigger listener
104     listener.apply( this, args ); 104     listener.apply( this, args );
105     // get next listener 105     // get next listener
106     i += isOnce ? 0 : 1; 106     i += isOnce ? 0 : 1;
107     listener = listeners[i]; 107     listener = listeners[i];
108   } 108   }
109  109 
110   return this; 110   return this;
111 }; 111 };
112  112 
113 return EvEmitter; 113 return EvEmitter;
114  114 
115 })); 115 }));
116  116 
117 /*! 117 /*!
118  * imagesLoaded v4.1.0 118  * imagesLoaded v4.1.0
119  * JavaScript is all like "You images are done yet or what?" 119  * JavaScript is all like "You images are done yet or what?"
120  * MIT License 120  * MIT License
121  */ 121  */
122  122 
123 ( function( window, factory ) { 'use strict'; 123 ( function( window, factory ) { 'use strict';
124   // universal module definition 124   // universal module definition
125  125 
126   /*global define: false, module: false, require: false */ 126   /*global define: false, module: false, require: false */
127  127 
128   if ( typeof define == 'function' && define.amd ) { 128   if ( typeof define == 'function' && define.amd ) {
129     // AMD 129     // AMD
130     define( [ 130     define( [
131       'ev-emitter/ev-emitter' 131       'ev-emitter/ev-emitter'
132     ], function( EvEmitter ) { 132     ], function( EvEmitter ) {
133       return factory( window, EvEmitter ); 133       return factory( window, EvEmitter );
134     }); 134     });
135   } else if ( typeof module == 'object' && module.exports ) { 135   } else if ( typeof module == 'object' && module.exports ) {
136     // CommonJS 136     // CommonJS
137     module.exports = factory( 137     module.exports = factory(
138       window, 138       window,
139       require('ev-emitter') 139       require('ev-emitter')
140     ); 140     );
141   } else { 141   } else {
142     // browser global 142     // browser global
143     window.imagesLoaded = factory( 143     window.imagesLoaded = factory(
144       window, 144       window,
145       window.EvEmitter 145       window.EvEmitter
146     ); 146     );
147   } 147   }
148  148 
149 })( window, 149 })( window,
150  150 
151 // --------------------------  factory -------------------------- // 151 // --------------------------  factory -------------------------- //
152  152 
153 function factory( window, EvEmitter ) { 153 function factory( window, EvEmitter ) {
154  154 
155  155 
156  156 
157 var $ = window.jQuery; 157 var $ = window.jQuery;
158 var console = window.console; 158 var console = window.console;
159  159 
160 // -------------------------- helpers -------------------------- // 160 // -------------------------- helpers -------------------------- //
161  161 
162 // extend objects 162 // extend objects
163 function extend( a, b ) { 163 function extend( a, b ) {
164   for ( var prop in b ) { 164   for ( var prop in b ) {
165     a[ prop ] = b[ prop ]; 165     a[ prop ] = b[ prop ];
166   } 166   }
167   return a; 167   return a;
168 } 168 }
169  169 
170 // turn element or nodeList into an array 170 // turn element or nodeList into an array
171 function makeArray( obj ) { 171 function makeArray( obj ) {
172   var ary = []; 172   var ary = [];
173   if ( Array.isArray( obj ) ) { 173   if ( Array.isArray( obj ) ) {
174     // use object if already an array 174     // use object if already an array
175     ary = obj; 175     ary = obj;
176   } else if ( typeof obj.length == 'number' ) { 176   } else if ( typeof obj.length == 'number' ) {
177     // convert nodeList to array 177     // convert nodeList to array
178     for ( var i=0; i < obj.length; i++ ) { 178     for ( var i=0; i < obj.length; i++ ) {
179       ary.push( obj[i] ); 179       ary.push( obj[i] );
180     } 180     }
181   } else { 181   } else {
182     // array of single index 182     // array of single index
183     ary.push( obj ); 183     ary.push( obj );
184   } 184   }
185   return ary; 185   return ary;
186 } 186 }
187  187 
188 // -------------------------- imagesLoaded -------------------------- // 188 // -------------------------- imagesLoaded -------------------------- //
189  189 
190 /** 190 /**
191  * @param {Array, Element, NodeList, String} elem 191  * @param {Array, Element, NodeList, String} elem
192  * @param {Object or Function} options - if function, use as callback 192  * @param {Object or Function} options - if function, use as callback
193  * @param {Function} onAlways - callback function 193  * @param {Function} onAlways - callback function
194  */ 194  */
195 function ImagesLoaded( elem, options, onAlways ) { 195 function ImagesLoaded( elem, options, onAlways ) {
196   // coerce ImagesLoaded() without new, to be new ImagesLoaded() 196   // coerce ImagesLoaded() without new, to be new ImagesLoaded()
197   if ( !( this instanceof ImagesLoaded ) ) { 197   if ( !( this instanceof ImagesLoaded ) ) {
198     return new ImagesLoaded( elem, options, onAlways ); 198     return new ImagesLoaded( elem, options, onAlways );
199   } 199   }
200   // use elem as selector string 200   // use elem as selector string
201   if ( typeof elem == 'string' ) { 201   if ( typeof elem == 'string' ) {
202     elem = document.querySelectorAll( elem ); 202     elem = document.querySelectorAll( elem );
203   } 203   }
204  204 
205   this.elements = makeArray( elem ); 205   this.elements = makeArray( elem );
206   this.options = extend( {}, this.options ); 206   this.options = extend( {}, this.options );
207  207 
208   if ( typeof options == 'function' ) { 208   if ( typeof options == 'function' ) {
209     onAlways = options; 209     onAlways = options;
210   } else { 210   } else {
211     extend( this.options, options ); 211     extend( this.options, options );
212   } 212   }
213  213 
214   if ( onAlways ) { 214   if ( onAlways ) {
215     this.on( 'always', onAlways ); 215     this.on( 'always', onAlways );
216   } 216   }
217  217 
218   this.getImages(); 218   this.getImages();
219  219 
220   if ( $ ) { 220   if ( $ ) {
221     // add jQuery Deferred object 221     // add jQuery Deferred object
222     this.jqDeferred = new $.Deferred(); 222     this.jqDeferred = new $.Deferred();
223   } 223   }
224  224 
225   // HACK check async to allow time to bind listeners 225   // HACK check async to allow time to bind listeners
226   setTimeout( function() { 226   setTimeout( function() {
227     this.check(); 227     this.check();
228   }.bind( this )); 228   }.bind( this ));
229 } 229 }
230  230 
231 ImagesLoaded.prototype = Object.create( EvEmitter.prototype ); 231 ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
232  232 
233 ImagesLoaded.prototype.options = {}; 233 ImagesLoaded.prototype.options = {};
234  234 
235 ImagesLoaded.prototype.getImages = function() { 235 ImagesLoaded.prototype.getImages = function() {
236   this.images = []; 236   this.images = [];
237  237 
238   // filter & find items if we have an item selector 238   // filter & find items if we have an item selector
239   this.elements.forEach( this.addElementImages, this ); 239   this.elements.forEach( this.addElementImages, this );
240 }; 240 };
241  241 
242 /** 242 /**
243  * @param {Node} element 243  * @param {Node} element
244  */ 244  */
245 ImagesLoaded.prototype.addElementImages = function( elem ) { 245 ImagesLoaded.prototype.addElementImages = function( elem ) {
246   // filter siblings 246   // filter siblings
247   if ( elem.nodeName == 'IMG' ) { 247   if ( elem.nodeName == 'IMG' ) {
248     this.addImage( elem ); 248     this.addImage( elem );
249   } 249   }
250   // get background image on element 250   // get background image on element
251   if ( this.options.background === true ) { 251   if ( this.options.background === true ) {
252     this.addElementBackgroundImages( elem ); 252     this.addElementBackgroundImages( elem );
253   } 253   }
254  254 
255   // find children 255   // find children
256   // no non-element nodes, #143 256   // no non-element nodes, #143
257   var nodeType = elem.nodeType; 257   var nodeType = elem.nodeType;
258   if ( !nodeType || !elementNodeTypes[ nodeType ] ) { 258   if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
259     return; 259     return;
260   } 260   }
261   var childImgs = elem.querySelectorAll('img'); 261   var childImgs = elem.querySelectorAll('img');
262   // concat childElems to filterFound array 262   // concat childElems to filterFound array
263   for ( var i=0; i < childImgs.length; i++ ) { 263   for ( var i=0; i < childImgs.length; i++ ) {
264     var img = childImgs[i]; 264     var img = childImgs[i];
265     this.addImage( img ); 265     this.addImage( img );
266   } 266   }
267  267 
268   // get child background images 268   // get child background images
269   if ( typeof this.options.background == 'string' ) { 269   if ( typeof this.options.background == 'string' ) {
270     var children = elem.querySelectorAll( this.options.background ); 270     var children = elem.querySelectorAll( this.options.background );
271     for ( i=0; i < children.length; i++ ) { 271     for ( i=0; i < children.length; i++ ) {
272       var child = children[i]; 272       var child = children[i];
273       this.addElementBackgroundImages( child ); 273       this.addElementBackgroundImages( child );
274     } 274     }
275   } 275   }
276 }; 276 };
277  277 
278 var elementNodeTypes = { 278 var elementNodeTypes = {
279   1: true, 279   1: true,
280   9: true, 280   9: true,
281   11: true 281   11: true
282 }; 282 };
283  283 
284 ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) { 284 ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
285   var style = getComputedStyle( elem ); 285   var style = getComputedStyle( elem );
286   if ( !style ) { 286   if ( !style ) {
287     // Firefox returns null if in a hidden iframe https://bugzil.la/548397 287     // Firefox returns null if in a hidden iframe https://bugzil.la/548397
288     return; 288     return;
289   } 289   }
290   // get url inside url("...") 290   // get url inside url("...")
291   var reURL = /url\((['"])?(.*?)\1\)/gi; 291   var reURL = /url\((['"])?(.*?)\1\)/gi;
292   var matches = reURL.exec( style.backgroundImage ); 292   var matches = reURL.exec( style.backgroundImage );
293   while ( matches !== null ) { 293   while ( matches !== null ) {
294     var url = matches && matches[2]; 294     var url = matches && matches[2];
295     if ( url ) { 295     if ( url ) {
296       this.addBackground( url, elem ); 296       this.addBackground( url, elem );
297     } 297     }
298     matches = reURL.exec( style.backgroundImage ); 298     matches = reURL.exec( style.backgroundImage );
299   } 299   }
300 }; 300 };
301  301 
302 /** 302 /**
303  * @param {Image} img 303  * @param {Image} img
304  */ 304  */
305 ImagesLoaded.prototype.addImage = function( img ) { 305 ImagesLoaded.prototype.addImage = function( img ) {
306   var loadingImage = new LoadingImage( img ); 306   var loadingImage = new LoadingImage( img );
307   this.images.push( loadingImage ); 307   this.images.push( loadingImage );
308 }; 308 };
309  309 
310 ImagesLoaded.prototype.addBackground = function( url, elem ) { 310 ImagesLoaded.prototype.addBackground = function( url, elem ) {
311   var background = new Background( url, elem ); 311   var background = new Background( url, elem );
312   this.images.push( background ); 312   this.images.push( background );
313 }; 313 };
314  314 
315 ImagesLoaded.prototype.check = function() { 315 ImagesLoaded.prototype.check = function() {
316   var _this = this; 316   var _this = this;
317   this.progressedCount = 0; 317   this.progressedCount = 0;
318   this.hasAnyBroken = false; 318   this.hasAnyBroken = false;
319   // complete if no images 319   // complete if no images
320   if ( !this.images.length ) { 320   if ( !this.images.length ) {
321     this.complete(); 321     this.complete();
322     return; 322     return;
323   } 323   }
324  324 
325   function onProgress( image, elem, message ) { 325   function onProgress( image, elem, message ) {
326     // HACK - Chrome triggers event before object properties have changed. #83 326     // HACK - Chrome triggers event before object properties have changed. #83
327     setTimeout( function() { 327     setTimeout( function() {
328       _this.progress( image, elem, message ); 328       _this.progress( image, elem, message );
329     }); 329     });
330   } 330   }
331  331 
332   this.images.forEach( function( loadingImage ) { 332   this.images.forEach( function( loadingImage ) {
333     loadingImage.once( 'progress', onProgress ); 333     loadingImage.once( 'progress', onProgress );
334     loadingImage.check(); 334     loadingImage.check();
335   }); 335   });
336 }; 336 };
337  337 
338 ImagesLoaded.prototype.progress = function( image, elem, message ) { 338 ImagesLoaded.prototype.progress = function( image, elem, message ) {
339   this.progressedCount++; 339   this.progressedCount++;
340   this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded; 340   this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
341   // progress event 341   // progress event
342   this.emitEvent( 'progress', [ this, image, elem ] ); 342   this.emitEvent( 'progress', [ this, image, elem ] );
343   if ( this.jqDeferred && this.jqDeferred.notify ) { 343   if ( this.jqDeferred && this.jqDeferred.notify ) {
344     this.jqDeferred.notify( this, image ); 344     this.jqDeferred.notify( this, image );
345   } 345   }
346   // check if completed 346   // check if completed
347   if ( this.progressedCount == this.images.length ) { 347   if ( this.progressedCount == this.images.length ) {
348     this.complete(); 348     this.complete();
349   } 349   }
350  350 
351   if ( this.options.debug && console ) { 351   if ( this.options.debug && console ) {
352     console.log( 'progress: ' + message, image, elem ); 352     console.log( 'progress: ' + message, image, elem );
353   } 353   }
354 }; 354 };
355  355 
356 ImagesLoaded.prototype.complete = function() { 356 ImagesLoaded.prototype.complete = function() {
357   var eventName = this.hasAnyBroken ? 'fail' : 'done'; 357   var eventName = this.hasAnyBroken ? 'fail' : 'done';
358   this.isComplete = true; 358   this.isComplete = true;
359   this.emitEvent( eventName, [ this ] ); 359   this.emitEvent( eventName, [ this ] );
360   this.emitEvent( 'always', [ this ] ); 360   this.emitEvent( 'always', [ this ] );
361   if ( this.jqDeferred ) { 361   if ( this.jqDeferred ) {
362     var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve'; 362     var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
363     this.jqDeferred[ jqMethod ]( this ); 363     this.jqDeferred[ jqMethod ]( this );
364   } 364   }
365 }; 365 };
366  366 
367 // --------------------------  -------------------------- // 367 // --------------------------  -------------------------- //
368  368 
369 function LoadingImage( img ) { 369 function LoadingImage( img ) {
370   this.img = img; 370   this.img = img;
371 } 371 }
372  372 
373 LoadingImage.prototype = Object.create( EvEmitter.prototype ); 373 LoadingImage.prototype = Object.create( EvEmitter.prototype );
374  374 
375 LoadingImage.prototype.check = function() { 375 LoadingImage.prototype.check = function() {
376   // If complete is true and browser supports natural sizes, 376   // If complete is true and browser supports natural sizes,
377   // try to check for image status manually. 377   // try to check for image status manually.
378   var isComplete = this.getIsImageComplete(); 378   var isComplete = this.getIsImageComplete();
379   if ( isComplete ) { 379   if ( isComplete ) {
380     // report based on naturalWidth 380     // report based on naturalWidth
381     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 381     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
382     return; 382     return;
383   } 383   }
384  384 
385   // If none of the checks above matched, simulate loading on detached element. 385   // If none of the checks above matched, simulate loading on detached element.
386   this.proxyImage = new Image(); 386   this.proxyImage = new Image();
387   this.proxyImage.addEventListener( 'load', this ); 387   this.proxyImage.addEventListener( 'load', this );
388   this.proxyImage.addEventListener( 'error', this ); 388   this.proxyImage.addEventListener( 'error', this );
389   // bind to image as well for Firefox. #191 389   // bind to image as well for Firefox. #191
390   this.img.addEventListener( 'load', this ); 390   this.img.addEventListener( 'load', this );
391   this.img.addEventListener( 'error', this ); 391   this.img.addEventListener( 'error', this );
392   this.proxyImage.src = this.img.src; 392   this.proxyImage.src = this.img.src;
393 }; 393 };
394  394 
395 LoadingImage.prototype.getIsImageComplete = function() { 395 LoadingImage.prototype.getIsImageComplete = function() {
396   return this.img.complete && this.img.naturalWidth !== undefined; 396   return this.img.complete && this.img.naturalWidth !== undefined;
397 }; 397 };
398  398 
399 LoadingImage.prototype.confirm = function( isLoaded, message ) { 399 LoadingImage.prototype.confirm = function( isLoaded, message ) {
400   this.isLoaded = isLoaded; 400   this.isLoaded = isLoaded;
401   this.emitEvent( 'progress', [ this, this.img, message ] ); 401   this.emitEvent( 'progress', [ this, this.img, message ] );
402 }; 402 };
403  403 
404 // ----- events ----- // 404 // ----- events ----- //
405  405 
406 // trigger specified handler for event type 406 // trigger specified handler for event type
407 LoadingImage.prototype.handleEvent = function( event ) { 407 LoadingImage.prototype.handleEvent = function( event ) {
408   var method = 'on' + event.type; 408   var method = 'on' + event.type;
409   if ( this[ method ] ) { 409   if ( this[ method ] ) {
410     this[ method ]( event ); 410     this[ method ]( event );
411   } 411   }
412 }; 412 };
413  413 
414 LoadingImage.prototype.onload = function() { 414 LoadingImage.prototype.onload = function() {
415   this.confirm( true, 'onload' ); 415   this.confirm( true, 'onload' );
416   this.unbindEvents(); 416   this.unbindEvents();
417 }; 417 };
418  418 
419 LoadingImage.prototype.onerror = function() { 419 LoadingImage.prototype.onerror = function() {
420   this.confirm( false, 'onerror' ); 420   this.confirm( false, 'onerror' );
421   this.unbindEvents(); 421   this.unbindEvents();
422 }; 422 };
423  423 
424 LoadingImage.prototype.unbindEvents = function() { 424 LoadingImage.prototype.unbindEvents = function() {
425   this.proxyImage.removeEventListener( 'load', this ); 425   this.proxyImage.removeEventListener( 'load', this );
426   this.proxyImage.removeEventListener( 'error', this ); 426   this.proxyImage.removeEventListener( 'error', this );
427   this.img.removeEventListener( 'load', this ); 427   this.img.removeEventListener( 'load', this );
428   this.img.removeEventListener( 'error', this ); 428   this.img.removeEventListener( 'error', this );
429 }; 429 };
430  430 
431 // -------------------------- Background -------------------------- // 431 // -------------------------- Background -------------------------- //
432  432 
433 function Background( url, element ) { 433 function Background( url, element ) {
434   this.url = url; 434   this.url = url;
435   this.element = element; 435   this.element = element;
436   this.img = new Image(); 436   this.img = new Image();
437 } 437 }
438  438 
439 // inherit LoadingImage prototype 439 // inherit LoadingImage prototype
440 Background.prototype = Object.create( LoadingImage.prototype ); 440 Background.prototype = Object.create( LoadingImage.prototype );
441  441 
442 Background.prototype.check = function() { 442 Background.prototype.check = function() {
443   this.img.addEventListener( 'load', this ); 443   this.img.addEventListener( 'load', this );
444   this.img.addEventListener( 'error', this ); 444   this.img.addEventListener( 'error', this );
445   this.img.src = this.url; 445   this.img.src = this.url;
446   // check if image is already complete 446   // check if image is already complete
447   var isComplete = this.getIsImageComplete(); 447   var isComplete = this.getIsImageComplete();
448   if ( isComplete ) { 448   if ( isComplete ) {
449     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 449     this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
450     this.unbindEvents(); 450     this.unbindEvents();
451   } 451   }
452 }; 452 };
453  453 
454 Background.prototype.unbindEvents = function() { 454 Background.prototype.unbindEvents = function() {
455   this.img.removeEventListener( 'load', this ); 455   this.img.removeEventListener( 'load', this );
456   this.img.removeEventListener( 'error', this ); 456   this.img.removeEventListener( 'error', this );
457 }; 457 };
458  458 
459 Background.prototype.confirm = function( isLoaded, message ) { 459 Background.prototype.confirm = function( isLoaded, message ) {
460   this.isLoaded = isLoaded; 460   this.isLoaded = isLoaded;
461   this.emitEvent( 'progress', [ this, this.element, message ] ); 461   this.emitEvent( 'progress', [ this, this.element, message ] );
462 }; 462 };
463  463 
464 // -------------------------- jQuery -------------------------- // 464 // -------------------------- jQuery -------------------------- //
465  465 
466 ImagesLoaded.makeJQueryPlugin = function( jQuery ) { 466 ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
467   jQuery = jQuery || window.jQuery; 467   jQuery = jQuery || window.jQuery;
468   if ( !jQuery ) { 468   if ( !jQuery ) {
469     return; 469     return;
470   } 470   }
471   // set local variable 471   // set local variable
472   $ = jQuery; 472   $ = jQuery;
473   // $().imagesLoaded() 473   // $().imagesLoaded()
474   $.fn.imagesLoaded = function( options, callback ) { 474   $.fn.imagesLoaded = function( options, callback ) {
475     var instance = new ImagesLoaded( this, options, callback ); 475     var instance = new ImagesLoaded( this, options, callback );
476     return instance.jqDeferred.promise( $(this) ); 476     return instance.jqDeferred.promise( $(this) );
477   }; 477   };
478 }; 478 };
479 // try making plugin 479 // try making plugin
480 ImagesLoaded.makeJQueryPlugin(); 480 ImagesLoaded.makeJQueryPlugin();
481  481 
482 // --------------------------  -------------------------- // 482 // --------------------------  -------------------------- //
483  483 
484 return ImagesLoaded; 484 return ImagesLoaded;
485  485 
486 }); 486 });